<?php
class DesignActivityContModel extends BaseModel {

	public function getList($map = null, $limit = null , $year = null){
		if(!$year){
			$options['table'] = 'm_design_activity_cont_'. date('Y');
		}else{
			$options['table'] = 'm_design_activity_cont_'. $year;
		}
		return $this->where($map)->order('year,month,day DESC')->limit($limit)->select($options);
	}

	public function getCount($map = null){
		$options['table'] = 'm_design_activity_cont_'. date('Y');
		$count =  $this->where($map)->field('count(1) as count')->select($options);
		return intval($count[0]['count']);
	}
	
	/**
	 * 根据年月统计通过率
	 * @param int $year
	 * @param int $month
	 * @author ice<iceinto@mallog.com.cn>
	 */
	public function getMonthPassing($year, $month){
		$options['table'] = 'm_design_activity_cont_'. $year;
		$map['year'] = $year;
		$map['month'] = $month;
		$users = $this->where($map)->field('uid,SUM(count) as all_count,SUM(return_count) as all_return_count')->group('uid')->select($options);
		return $users;
	}
}

?>